package com.buka.recipe.common.utils;

import cn.hutool.extra.servlet.JakartaServletUtil;
import jakarta.servlet.http.HttpServletRequest;

/**
 * Ip 工具
 *
 * @author admin
 */
public class IpUtils {

    /**
     * 获取客户端IP
     *
     * @param request 请求对象
     * @return IP地址
     */
    public static String getClientIp(HttpServletRequest request) {
        String clientIp = JakartaServletUtil.getClientIP(request);
        return "0:0:0:0:0:0:0:1".equals(clientIp) ? "127.0.0.1" : clientIp;
    }

}
